<template>
  <div class="charts" ref="charts"></div>
</template>

<script>
import * as Echarts from "echarts";
export default {
  name: "LineCharts",
  mounted() {
    let lineCharts = Echarts.init(this.$refs.charts);
    lineCharts.setOption({
      xAxis: {
        // 隐藏 X 抽
        show: false,
        // 控制线条为折线 而不是直线
        type: "category"
      },
      yAxis: {
        // 隐藏 Y 抽
        show: false
      },
      series: [
        {
          type: "line",
          data: [10, 30, 5, 20, 10, 30],
          // 拐点样式的设置
          itemStyle: {
            opacity: 0
          },
          // 线条颜色
          lineStyle: {
            color: "purple"
          },
          // 颜色填充
          areaStyle: {
            color: {
              type: "linear",
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              // 渐变色或者纹理填充
              colorStops: [
                {
                  offset: 0,
                  color: "purple" // 0% 处的颜色
                },
                {
                  offset: 1,
                  color: "white" // 100% 处的颜色
                }
              ],
              global: false // 缺省为 false
            }
          },
          // 弧度设置
          smooth:true
        }
      ],
      // 布局
      grid: {
        left: 0,
        top: 10,
        right: 0,
        bottom: 0
      }
    });
  }
};
</script>

<style scoped>
.charts {
  width: 100%;
  height: 50px;
}
</style>